package com.example.demo.util;

/**
 * @Classname BlankDemo
 * @Description TODO
 * @Date 2019/10/10 16:37
 * @Created by yby
 */
public class BlankDemo {

    public String addBlank(int n, String str) {
        str = String.format("%1$" + (n + 2) + "s", str);
        System.out.println(str);
        return str;
    }

    public static void main(String[] args) {
        String str = "你好";
        BlankDemo blankDemo = new BlankDemo();
        str = blankDemo.addBlank(8, str);
        //System.out.println(str);
        //System.out.printf("新字符串长度：%d\n", str.length());
        /*str = "你好";
        System.out.println(String.format("%1$1s", str));  //左补齐
        System.out.println(String.format("%1$2s", str));  //左补齐
        System.out.println(String.format("%1$10s", str));  //左补齐*/
        System.out.println("        你好");  //左补齐

        //8  补10
    }
}
